package newjdk8.stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

public class Stream {


    public static void main(String[] args) {

        List<Student> students = new ArrayList<Student>();
        for (int i = 0;i<20;i++){
            Student student = new Student();
            student.setId(i);
            student.setName("学生"+i);
            student.setAge(10+i);
            students.add(student);
        }
        List<Student> students1 =students.stream().filter(student -> student.getAge()>18).collect(Collectors.toList());
        students1.forEach(Student::test);

        Random random = new Random();
        random.ints().limit(10).sorted().forEach(System.out::println);

    }
}

class Student{
    private int id;
    private String name;
    private int age;


    public void test(){

    };
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return 0;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
